package cpt202.project.config;

import cpt202.project.Interceptor.loginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.ArrayList;
import java.util.List;


//为过滤器添加白名单
@Configuration
//作为注解类自动加载
public class LoginInterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        HandlerInterceptor interceptor = new loginInterceptor();
        List<String> WhiteList = new ArrayList<>();
        WhiteList.add("/css/**");
        WhiteList.add("/font/**");
        WhiteList.add("/images/**");
        WhiteList.add("/js/**");
        WhiteList.add("/web/登录.html");
        WhiteList.add("/User/login");
        WhiteList.add("/User/resetpsw");
        WhiteList.add("/User/reg");
        //拦截器注册
        registry.addInterceptor(interceptor).addPathPatterns("/**").excludePathPatterns(WhiteList);
    }
}
